package com.nowcoder.community.entity;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * 封装的事件
 */
@Getter
public class Event {
    // 主题
    private String topic;
    // 触发事件的人
    private int userId;
    // 触发事件的实体类型
    private int entityType;
    // 触发事件的实体id
    private int entityId;
    // 触发事件的实体拥有者的id
    private int entityUserId;

    // 扩展信息
    private Map<String,Object> data = new HashMap<>();

    public Event setTopic(String topic) {
        this.topic = topic;
        return this;
    }

    public Event setUserId(int userId) {
        this.userId = userId;
        return this;
    }

    public Event setEntityType(int entityType) {
        this.entityType = entityType;
        return this;
    }

    public Event setEntityId(int entityId) {
        this.entityId = entityId;
        return this;
    }

    public Event setEntityUserId(int entityUserId) {
        this.entityUserId = entityUserId;
        return this;
    }

    public Event setData(String key,Object value) {
        this.data.put(key,value);
        return this;
    }
}
